/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bitly;

import java.net.URL;

/**
 *
 * @author Demon
 */
public class BitlyUrl {

    private String domain;
    private String url;
    private boolean isHttps;
    public String shortDomain = "cf.fm";
    public String finalUrl;

    /**
     *
     */
    public BitlyUrl() {
        this.domain = null;
        this.url = null;
        this.isHttps = false;
    }

    /**
     *
     * @param url
     */
    public BitlyUrl(URL url) {
        this.isHttps = (url.getProtocol().equals("http")) ? false : true;
        this.domain = url.getHost();
        this.url = url.getPath();
    }

    /**
     *
     * @param d
     * @param u
     * @param h
     */
    public BitlyUrl(String d, String u, boolean h) {
        domain = d;
        url = u;
        isHttps = h;
    }

    /**
     *
     * @param d
     */
    public void setDomain(String d) {
        domain = d;
    }

    /**
     *
     * @param u
     */
    public void setUrl(String u) {
        url = u;
    }

    /**
     *
     * @param h
     */
    public void setIsHttps(boolean h) {
        isHttps = h;

    }

    /**
     *
     * @return
     */
    public String getDomain() {
        return domain;
    }

    /**
     *
     * @return
     */
    public String getUrl() {
        return url;
    }

    /**
     *
     * @return
     */
    public boolean getIsHttps() {
        return isHttps;

    }

    public String getFinallUrl(String shortUrl){
        StringBuilder sb = new StringBuilder();
        if(isHttps)
            sb.append("https");
        else
            sb.append("http");
        sb.append("://");
        sb.append(this.shortDomain);
        sb.append("/");
        sb.append(shortUrl);

        return sb.toString();

            
    }
}
